
package com.eyedog.video.videolist;

import android.util.Log;

import com.eyedog.video.entity.VideoEntity;

import java.util.HashMap;
import java.util.List;

public class VideoInstance {
    private static final String TAG = "VideoInstance";

    static HashMap<Integer, List<VideoEntity>> videoCaches = new HashMap<>();

    public static List<VideoEntity> getVideoFromCache(int categoryId, int page) {
        List<VideoEntity> videoEntities = videoCaches.get(categoryId);
        page = page - 1;
        int startIndex = page * 10;
        if (videoEntities != null && videoEntities.size() > startIndex) {
            List<VideoEntity> resultEntities = videoEntities.subList(startIndex,
                    videoEntities.size());
            return resultEntities;
        }
        return null;
    }

    public static List<VideoEntity> getVideoFromCache(int categoryId) {
        return videoCaches.get(categoryId);
    }

    public static void putVideoEntity(int categoryId, List<VideoEntity> videoEntities) {
        Log.i(TAG, "putVideoEntity,categoryId:" + categoryId + "；" + videoEntities.size());
        videoCaches.put(categoryId, videoEntities);
    }
}
